package bb.lanxing.databinding.unit;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

public class HeightUnit extends Unit {
    public static float LegalBritishMaxFTNum = 10.0f;
    public static float LegalBritishMaxNum = 90.0f;
    public static float LegalBritishMinFTNum = 3.0f;
    public static float LegalBritishMinNum = 20.0f;
    public static float LegalMetricMaxNum = 230.0f;
    public static float LegalMetricMinNum = 50.0f;

    public HeightUnit(String str) {
        super(str, "m");
    }

    public HeightUnit(String str, DecimalFormat decimalFormat) {
        super(str, "m", decimalFormat);
    }

    public HeightUnit(String str, String str2, DecimalFormat decimalFormat) {
        super(str, str2, decimalFormat);
    }

    @Override
    String convertToMetric(String str, int i) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("2.54"));
        this.numberDecimalFormat.setMaximumFractionDigits(i);
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueMetric = this.numberDecimalFormat.format(multiply.setScale(i, RoundingMode.HALF_UP));
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str, int i) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.39370079"));
        this.numberDecimalFormat.setMaximumFractionDigits(i);
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueBritish = this.numberDecimalFormat.format(multiply.setScale(i, RoundingMode.HALF_UP));
        return this.valueBritish;
    }

    @Override
    String convertToMetric(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("2.54"));
        this.numberDecimalFormat.setMinimumFractionDigits(0);
        this.valueMetric = this.numberDecimalFormat.format(multiply);
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.39370079"));
        this.numberDecimalFormat.setMinimumFractionDigits(0);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }

    @Override
    public String getUnitString(String str) {
        return str.equals("m") ? " cm" : str.equals("f") ? " in" : "";
    }

    public String inch2Ft(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.08333333"));
        this.numberDecimalFormat.setMinimumFractionDigits(2);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }

    public String ft2Inch(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("12"));
        this.numberDecimalFormat.setMinimumFractionDigits(0);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }

    public String cm2Ft(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.032808399"));
        this.numberDecimalFormat.setMinimumFractionDigits(2);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }
}
